function addMarker(points) { // 创建图标对象
    //	console.log(points)
    // 百度地图API功能
    map = new BMap.Map("allmap");
    var pointInit = new BMap.Point(116.506363, 39.953382);

    var myIcon = new BMap.Icon("../statics/img/ed.png", new BMap.Size(32, 32));
    var geolocation = new BMap.Geolocation();
	var my_lng = 116.506363;
	var my_lat = 39.953382;
    geolocation.getCurrentPosition(function(r) {
        if(this.getStatus() == BMAP_STATUS_SUCCESS) {

            map.centerAndZoom(pointInit,12);

            var mk = new BMap.Marker(r.point);
            map.addOverlay(mk);
            // map.panTo(r.point);
            my_lng = r.point.lng;
            my_lat = r.point.lat;
            var waypoints = [];
            // 创建标注对象并添加到地图
            for(var i = 0, pointsLen = points.length; i < pointsLen; i++) {
                var point = new BMap.Point(points[i].longtitude, points[i].atitude);
                //		var marker = new BMap.Marker(point,{
                //			icon:myIcon
                //		});
                var marker = new BMap.Marker(point);
                map.addOverlay(marker);
                var driving = new BMap.DrivingRoute(map, {
                    renderOptions: {
                        map: map,
                        autoViewport: true
                    }
                });

                //给标注点添加点击事件。使用立即执行函数和闭包
                (function() {
                    var thePoint = points[i];
                    marker.addEventListener("click", function() {
                        showInfo(this, thePoint);
                    });
                })();
                waypoints.push(new BMap.Point(points[i].longtitude, points[i].atitude));
            }

            if (app.state==1) {
//				var s_start = new BMap.Point(my_lng, my_lat);
                var s_start = new BMap.Point(points[0].longtitude, points[0].atitude);
                var s_end = new BMap.Point(points[points.length - 1].longtitude, points[points.length - 1].atitude);
                driving.search(s_start, s_end, {
                    waypoints: waypoints
                });
            }

            //			alert('您的位置：'+r.point.lng+','+r.point.lat);
        } else {
            alert('failed' + this.getStatus());
        }
    }, {
        enableHighAccuracy: true
    })

}
//显示信息窗口，显示标注点的信息。
function showInfo(thisMaker, point) {
    var sContent =
        '<ul style="margin:0 0 5px 0;padding:0.2em 0">' +
        '<li style="line-height: 26px;font-size: 15px;">' +
        '<span class="colorH" style="display: inline-block;">类型：</span>' + point.sensortype + '</li>' +
        '<li style="line-height: 26px;font-size: 15px;">' +
        '<span class="colorH" style="display: inline-block;">当前电量：</span>' + point.electricity + '</li>' +
        '<li style="line-height: 26px;font-size: 15px;">' +
        '<span  class="colorH" style="display: inline-block;">地址：</span>' + point.address + '</li>' +
        '<li style="line-height: 26px;font-size: 15px;"><span class="colorH" style="display: inline-block;">路线：</span><a onclick="getDriving(' + point.longtitude + ',' + point.atitude + ')">点击前往</a></li>' +
        '</ul>';
    var infoWindow = new BMap.InfoWindow(sContent); // 创建信息窗口对象
    thisMaker.openInfoWindow(infoWindow); //图片加载完毕重绘infowindow
}

function getDriving(go_lng, go_lat) {
    var p1 = new BMap.Point(my_lng, my_lat);
    var p2 = new BMap.Point(go_lng, go_lat);
    var driving = new BMap.DrivingRoute(map, {
        renderOptions: {
            map: map,
            autoViewport: true
        }
    });
    driving.search(p1, p2);
}